import re

import requests

resp = requests.get(
    url='https://movie.douban.com/top250',
    headers={
        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'
    }
)
# 418 - I am a teapot.
print(resp.status_code)
# print(resp.text)

# 使用正则表达式捕获组从页面代码中提取电影名称
pattern = re.compile(r'\<span class="title"\>(.*?)\<\/span\>')
print(type(pattern))
print(pattern.findall(resp.text))
